#pragma once

#include <QtWidgets/QDialog>
#include "ui_QChatMainDlg.h"


QT_BEGIN_NAMESPACE
namespace Ui { class QChatMainDlgClass; };
QT_END_NAMESPACE


class UserInfo;


class HChatMainDlg : public QDialog
{
    Q_OBJECT

public:
    HChatMainDlg(QWidget *parent = nullptr);
    ~HChatMainDlg();

public slots:
    void OnSendMessage();

    void OnConnectSrv();

    void OnQueryUserNameResult(bool isOk, QString const& errMsg);

    void OnLoginResult(bool isOk, QString const& userName, QString const& token, QString const& errMsg);

    void OnGetUserInfoListResult(QString const& userName, QString const& token, QVector<UserInfo> const& userInfoList);
    
    void OnGetUserMessage(QString const& userName, QString const& msg);

protected:
    void InitSlotFun();
    void CloseConnection();

    void timerEvent(QTimerEvent* event);

private:
    Ui::QChatMainDlgClass *ui;
    QTcpSocket* m_pTcpSock = nullptr;
    QString m_ClientToken;
    int m_GetUserListTimerId = -1;
};
